package com.study.testSpringBoot.interceptor.testController;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.study.testSpringBoot.interceptor.anno.CheckParams;
import com.study.testSpringBoot.interceptor.service.TestService;
import com.study.testSpringBoot.interceptor.vo.User;

@RestController
public class TestAnnoInterceptor {
	
	@Autowired
	TestService testService;

	@CheckParams(isNull = true) 
	@RequestMapping("/testAnno")
	public String testAnno(String name) {
		System.out.println("参数名：" + name);
		return "SUCCESS";
	}
	
	@CheckParams(isNull = true) 
	@PostMapping("/testAnno")
	public String testAnno1(@RequestBody String name) {
		System.out.println("参数名---：" + name);
		return "SUCCESS";
	}
	
	@PostMapping("/testAnnoUser")
	public String testAnno2(@Validated User user, String nikename) {
		testService.test(user, nikename);
		return "SUCCESS";
	}
}
